#ifndef PATHSUBCLASS_H
#define PATHSUBCLASS_H

#include <QGraphicsPathItem>
#include "rectsubclass.h"
#include <QGraphicsSceneContextMenuEvent>
#include <QMenu>
#include <QAction>
#include <QGraphicsSceneHoverEvent>
class pathSubClass : public QObject, public QGraphicsPathItem
{
    Q_OBJECT
public:
    pathSubClass();
    pathSubClass(int number);
    pathSubClass(QPainterPath path, int number);
    pathSubClass(pathSubClass *myItem);
    pathSubClass(QPainterPath path, int number, int itemType);
    void setPathToItem(QPainterPath path);
    QPainterPath getPathFromItem();
    void addRectToMap(int count, rectSubClass *rItem);
    rectSubClass* getRectfromMap(int number);
    int getIndexVal();
    int getItemType();
    void removeRect(int i);
    QPointF getControlPoint(int index);
    void setControlPoint(QPointF myPoint, int index);
    QPointF getTempPoint(int index);
    void setTempPoint(QPointF myPoint, int index);

    void setMyBasePath(QPainterPath path);
    void setMyPath(QPainterPath *path);
    QPainterPath getMyBasePath();

    int controlRectsCount();
public slots:
    void drawMyEndRects();
    void removeMyEndRects();
    void drawMyControlRects();
    void removeMyControlRects();
signals:
    void setCurrentItemIndex(int);
    void addRectsToScene(int,int);
    void removeRectsFromScene(int,int);
    void addControlRectsToScene(int,int);
    void removeControlRectsToScene(int,int);
protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
    void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
//    QRectF boundingRect() const;
//    QPainterPath shape() const;
private:
    int indexVal;
    int itemtype;
    QPen *myPen;
    QMap<int,rectSubClass* > controlRects;
    QPointF *temp_points[200];
    QPointF *controlPoints[100];
    QPainterPath *myBasePath;
    enum types {line=1,bezier=2,orphnLine=3,orphnBzr=4};

    QAction *drawEndRect;
    QAction *act_removeEndRect;
    QAction *drawControlRect;
    QAction *act_removeControlRect;
    QAction *joinTwoCurves;
    void initContextMenus();
};

#endif // PATHSUBCLASS_H
